using UnityEngine;
using UnityEngine.UI;

namespace Galgame
{
    public class SettingsManager : MonoBehaviour
    {
        public GameObject settingsPanel;
        public Slider volumeSlider;
        public Toggle fullscreenToggle;

        void Start()
        {
            settingsPanel.SetActive(false);
            volumeSlider.value = PlayerPrefs.GetFloat("MasterVolume", 1f);
            fullscreenToggle.isOn = Screen.fullScreen;
        }

        public void OpenSettings()
        {
            settingsPanel.SetActive(true);
        }

        public void CloseSettings()
        {
            settingsPanel.SetActive(false);
        }

        public void OnVolumeChanged(float value)
        {
            AudioListener.volume = value;
            PlayerPrefs.SetFloat("MasterVolume", value);
        }

        public void OnFullscreenChanged(bool isOn)
        {
            Screen.fullScreen = isOn;
        }
    }
}
